<?php
//$screen = Blyn::app()->getUIManager()->getCurrentScreen();
//$wxControl = $screen->getChildControl('BUIWXControl_1');
//$wxControl->renderView('booking_home', array()); ?>
<script type="text/javascript">
    $(document).ready(function() {
        $("#selectAll").click(function() {
            if ($(this).attr("checked") == "checked") {
                $(":checkbox").attr("checked", true);
            } else {
                $(":checkbox").attr("checked", false);
            }
        });

    });
</script> 
<script type="text/javascript">
    $(function() {
        $('.tree li:has(ul)').addClass('parent_li').find(' > span').attr('title', 'Collapse this branch');
        $('.tree li.parent_li > span').on('click', function(e) {
            var children = $(this).parent('li.parent_li').find(' > ul > li');
            if (children.is(":visible")) {
                children.hide('fast');
                $(this).attr('title', 'Expand this branch').find(' > i').addClass('icon-plus-sign').removeClass('icon-minus-sign');
            } else {
                children.show('fast');
                $(this).attr('title', 'Collapse this branch').find(' > i').addClass('icon-minus-sign').removeClass('icon-plus-sign');
            }
            e.stopPropagation();
        });
    });</script>
<script type="text/javascript">
    $(function() {
        $("#Event_Shop_CX").click(function() {
            document.getElementById("Event_Shop_CX_View").style.display = '';
            document.getElementById("Event_Clothes_CX_View").style.display = 'none';
        });
        $("#Event_Clothes_CX").click(function() {
            document.getElementById("Event_Shop_CX_View").style.display = 'none';
            document.getElementById("Event_Clothes_CX_View").style.display = '';
        });
    });</script>

<?php
if (!isset($availableList) || $availableList == NULL) {
    $availableList = array();
    if (isset($findText) && $findText != NULL) {
        if (isset($findContext) && $findContext != NULL) {
            $findContext = unserialize($findContext);
        } else {
            $findContext = Blyn::app()->getUIManager()->getCurrentScreen()->getContextVariable('findContext');
        }

        if ($findContext == NULL) {
            $availableList = Blyn::app()->getActiveApp()->findByFindText($findText);
        } else {
            $availableList = Blyn::app()->getActiveApp()->findByFindText($findText, $findContext);
        }
    }
}
?>
<!--
<table class="table table-hover">
    <thead>
        <tr>
            <th>
                <input type="checkbox"  id="selectAll"> 
            </th>
            <th><?php // echo '场地'; ?></th>
            <th><?php // echo '日期'; ?></th>
            <th><?php // echo '开始时间'; ?></th>
            <th><?php // echo '结束时间'; ?></th>
            <th><?php // echo '预定状态'; ?></th>
            <th><?php // echo '操作'; ?></th>
        </tr> 
    </thead>
    <fieldset>
        <tbody>
            <?php
//            foreach ($availableList as $id => $bookingItem) {
//                $date = date('Y-m-d', $bookingItem->getItem('startTime')->value);
//                $startTime = date('G:i:s', $bookingItem->getItem('startTime')->value);
//                $endTime = date('G:i:s', $bookingItem->getItem('endTime')->value);
                ?>
                <tr>
                    <td><label class="checkbox">
                            <input type="checkbox" name="checkbox[]" value="<?php // echo $id; ?>"> 
                        </label></td>
                    <td> <?php // echo $bookingItem->getItem('courtDisplayName')->value; ?> </td>
                    <td> <?php // echo $date; ?> </td> 
                    <td> <?php // echo $startTime; ?> </td>       
                    <td> <?php // echo $endTime; ?> </td>    
                    <td> <?php // echo $bookingItem->getItem('bookingStatus')->value; ?> </td>    
                    <td>
                        <div class="row-fluid">                         
                            <?php
//                            $id = $bookingItem->getId();
//                            $control1 = new BUIControl('bookingButton' . $id);
//                            $data = array(
//                                'bookingId' => $bookingItem->getId(),
//                            );
//                            if (isset($findText)) {
//                                $data['findText'] = $findText;
//                            }
//                            $control1->addRenderView('toggleButton', 'booking_add_toggleButton_1', $data);
//                            $control1->render();
                            ?>                             
                        </div>                      
                    </td>
                </tr>
            <?php // } ?>
        </tbody>
    </fieldset>
</table>-->

<style type="text/css">
.item {width: 100%;border-bottom: 1px solid #DEDEDE;}
.item .check_item {width: 5%;height: 60px;float: left;}
.item .image {width: 15%;height: 60px;float: left;}
.item .content {width: 58%;padding-left: 2%;float: left;padding-top: 10px;}
.item .content .title {width: 100%;height: 25px;}
.item .content .date {width: 100%;height: 25px;overflow: hidden;}
.item .option {width: 20%;height: 60px;float: left;}
</style>

<?php
foreach ($availableList as $id => $bookingItem) {
    $date = date('Y-m-d', $bookingItem->getItem('startTime')->value);
    $startTime = date('G:i:s', $bookingItem->getItem('startTime')->value);
    $endTime = date('G:i:s', $bookingItem->getItem('endTime')->value);
    ?>
    <div class="item">
        <div class="check_item"><input type="checkbox" name="checkbox1" value="1" data-role="none"/></div>
        <div class="image"><img src="<?php echo Yii::app()->request->baseUrl; ?>/images/mobile/place1.jpg" width="100%" height="100%"/></div>
        <div class="content">
            <div class="title"><?php echo $bookingItem->getItem('courtDisplayName')->value; ?></div>
            <div class="date"><?php echo $date; ?> <?php echo $startTime; ?>-<?php echo $endTime; ?> <?php echo  Yii::t('BWeSport', $bookingItem->getItem('bookingStatus')->value); ?></div>
        </div>
        <div class="option">
            <?php
            $id = $bookingItem->getId();
            $control1 = new BUIControl('bookingButton' . $id);
            $data = array(
                'bookingId' => $bookingItem->getId(),
            );
            if (isset($findText)) {
                $data['findText'] = $findText;
            }
            $control1->addRenderView('toggleButton', 'booking_add_toggleButton_1', $data);
            $control1->render();
            ?>
        </div>
        <div style="width:100%;height: 1px;clear: both;"></div>
    </div>
<?php } ?>


<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"></div>
<div><input type="hidden" name="curPageNo" value="1"></div>

<div data-role="controlgroup" data-type="horizontal" data-mini="true">
    <a href="javascript:void()" class="ui-btn ui-btn-corner-all">前一页</a>
    <a href="javascript:void()" class="ui-btn ui-btn-corner-all">1</a>
    <a href="javascript:void()" class="ui-btn ui-btn-corner-all">后一页</a>
</div>
<?php
$data = array();
$data['htmlOptions'] = array('class' => 'btn btn-primary');
$findContext = array();
if (!isset($findContext) || !is_array($findContext))
    $findContext = array();
if (isset($findText))
    $findContext['findText'] = $findText;

Blyn::app()->getUIManager()->getCurrentScreen()->addContextVariable('findContext', $findContext);
echo $control->getLink(
        array(
            'name' => '进入支付',
            'id' => 'showPayBooking'),array('htmlOptions' => array('class'=>"ui-btn ui-mini ui-btn-corner-all")));
?>
<script type="text/javascript">
$(document).ready(function() {
    $(".ui-shadow").removeClass("ui-shadow");
    $("#find").addClass("ui-btn-active");
    $("input[type=checkbox]").css("display","inline");
});
</script>